package cases.chapter09.chapter0902;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws UnknownHostException,
            IOException {
        //创建键盘录入对象
        Scanner sc = new Scanner(System.in);
        //创建客户端,指定ip地址和端口号
        Socket socket = new Socket("127.0.0.1", 54321);
        BufferedReader br = new BufferedReader(new
                InputStreamReader(socket.getInputStream()));    //获取输入流
        //获取输出流
        PrintStream ps = new PrintStream(socket.getOutputStream());
        //将字符串写到服务器去
        ps.println(sc.nextLine());
        System.out.println(br.readLine()); //将反转后的结果读出来
        socket.close();
    }
}


